using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;using Maxleaf.EDI.Domain.K3;

namespace Maxleaf.EDI.DataAccess.K3
{
    public class t_ItemMap : EntityTypeConfiguration<t_Item>
    {
        public t_ItemMap()
        {
            // Primary Key
            this.HasKey(t => t.FItemID);

            // Properties
            this.Property(t => t.FItemID)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);

            this.Property(t => t.FNumber)
                .IsRequired()
                .HasMaxLength(80);

            this.Property(t => t.FName)
                .IsRequired()
                .HasMaxLength(255);

            this.Property(t => t.FBrNo)
                .IsRequired()
                .HasMaxLength(10);

            this.Property(t => t.FFullNumber)
                .IsRequired()
                .HasMaxLength(80);

            this.Property(t => t.FShortNumber)
                .HasMaxLength(80);

            this.Property(t => t.FFullName)
                .HasMaxLength(250);

            this.Property(t => t.FModifyTime)
                .IsRequired()
                .IsFixedLength()
                .HasMaxLength(8)
                .IsRowVersion();

            // Table & Column Mappings
            this.ToTable("t_Item");
            this.Property(t => t.FItemID).HasColumnName("FItemID");
            this.Property(t => t.FItemClassID).HasColumnName("FItemClassID");
            this.Property(t => t.FExternID).HasColumnName("FExternID");
            this.Property(t => t.FNumber).HasColumnName("FNumber");
            this.Property(t => t.FParentID).HasColumnName("FParentID");
            this.Property(t => t.FLevel).HasColumnName("FLevel");
            this.Property(t => t.FDetail).HasColumnName("FDetail");
            this.Property(t => t.FName).HasColumnName("FName");
            this.Property(t => t.FUnUsed).HasColumnName("FUnUsed");
            this.Property(t => t.FBrNo).HasColumnName("FBrNo");
            this.Property(t => t.FFullNumber).HasColumnName("FFullNumber");
            this.Property(t => t.FDiff).HasColumnName("FDiff");
            this.Property(t => t.FDeleted).HasColumnName("FDeleted");
            this.Property(t => t.FShortNumber).HasColumnName("FShortNumber");
            this.Property(t => t.FFullName).HasColumnName("FFullName");
            this.Property(t => t.UUID).HasColumnName("UUID");
            this.Property(t => t.FGRCommonID).HasColumnName("FGRCommonID");
            this.Property(t => t.FSystemType).HasColumnName("FSystemType");
            this.Property(t => t.FUseSign).HasColumnName("FUseSign");
            this.Property(t => t.FChkUserID).HasColumnName("FChkUserID");
            this.Property(t => t.FAccessory).HasColumnName("FAccessory");
            this.Property(t => t.FGrControl).HasColumnName("FGrControl");
            this.Property(t => t.FModifyTime).HasColumnName("FModifyTime");

            // Relationships
            this.HasRequired(t => t.t_ItemClass)
                .WithMany(t => t.t_Item)
                .HasForeignKey(d => d.FItemClassID);
            this.HasRequired(t => t.t_Item2)
                .WithMany(t => t.t_Item1)
                .HasForeignKey(d => d.FParentID);

        }
    }
}
